package com.charging.business.media;

/**
 * CPC卡计费信息文件(DF01/EF04)的解码信息
 * @author lzj
 */
public class CpcEf04Model {
    public CpcProvModel[] provInfos = new CpcProvModel[22];

    /**
     * CPC卡计费信息文件(DF01/EF04)的解码信息
     */
    public CpcEf04Model() {
        for (int a = 0; a < 22; a++) {
            provInfos[a] = new CpcProvModel();
        }
    }

    /**
     * 获取最后过省信息
     *
     * @param provCnt - 过省数量
     * @return
     */
    public CpcProvModel lastProv(int provCnt) {
        if (provCnt > 0 && provCnt <= provInfos.length) {
            return provInfos[provCnt - 1];
        }
        return null;
    }

    /**
     * 获取全程过门架数量
     *
     * @param provCnt - 过省数量
     * @return
     */
    public int sumCount(int provCnt) {
        int ret = 0;
        if (provCnt > 0 && provCnt < provInfos.length) {
            for (int aa = 0; aa < provCnt; aa++) {
                CpcProvModel prov = provInfos[aa];
                ret += prov.gantryCount;
            }
        }
        return ret;
    }

    /**
     * 获取全程计费金额
     *
     * @param provCnt
     * @return
     */
    public int sumFee(int provCnt) {
        int ret = 0;
        if (provCnt > 0 && provCnt < provInfos.length) {
            for (int aa = 0; aa < provCnt; aa++) {
                CpcProvModel prov = provInfos[aa];
                ret += prov.provSumPayFee;
            }
        }
        return ret;
    }

    /**
     * 检查前序行程是否包含拟合失败标识
     *
     * @param hasNewTrip - 0:无新行程; 1:有新行程
     * @return
     */
    public boolean prevFitFaild(int provCnt, int hasNewTrip) {
        if (hasNewTrip == 1) {
            //有新行程(需要检查最后一段行程)
            provCnt++;
        }

        // 正常不含最后段行程
        for (int aa = 0; aa < provCnt - 1; aa++) {
            CpcProvModel dd = provInfos[aa];
            if (dd.newGantryFitting == 1) {
                return true;
            }
        }
        return false;
    }
}
